//
//  TitleCollectionReusableView.m
//  XiMaLaYa
//
//  Created by dllo on 15/11/12.
//  Copyright © 2015年 L-G. All rights reserved.
//

#import "TitleCollectionReusableView.h"

@implementation TitleCollectionReusableView
- (void)dealloc
{
    [_labelTitle release];
    [_labelMore release];
    [super dealloc];
}
#pragma mark 初始化
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.sortTitleLabel = [[UILabel alloc] init];
        [self addSubview:self.sortTitleLabel];
        self.sortTitleLabel.userInteractionEnabled = YES;
        
        UITapGestureRecognizer *firstTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(firstTap:)];
        [self.sortTitleLabel addGestureRecognizer:firstTap];
        
        self.labelTitle = [UILabel new];
        self.labelTitle.font = [UIFont systemFontOfSize:14];
        [self.sortTitleLabel addSubview:self.labelTitle];
        [_labelTitle release];
        
        self.labelMore = [UILabel new];
        self.labelMore.textColor = [UIColor grayColor];
        self.labelMore.font = [UIFont systemFontOfSize:14];
        self.labelMore.text = @"更多 >";
        [self.sortTitleLabel addSubview:self.labelMore];
        [_labelMore release];
    }
    return self;
}
- (void)firstTap:(id)sender
{
//    [self.delegate sendSection:self.section];
     self.myBlock(self.section);
}



#pragma mark 设置frame
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.sortTitleLabel.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    
    self.labelTitle.frame = CGRectMake(15, 8, self.frame.size.width - 100, self.frame.size.height - 10);
    
    self.labelMore.frame = CGRectMake(self.frame.size.width - 50, 8, 50, self.frame.size.height - 10);
}
#pragma mark set方法
- (void)setSortModel:(SortModel *)sortModel
{
    if (_sortModel != sortModel) {
        [_sortModel release];
        _sortModel = [sortModel retain];
    }
    self.labelTitle.text = sortModel.title;
}

@end
